<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('phone')->nullable();
            $table->string('email')->nullable()->change();
            $table->string('name')->nullable()->change();
            $table->string('password')->nullable()->change();
            $table->integer('head_id')->nullable()->default('0');
            $table->integer('status')->default(0);
            $table->string('last_login_ip')->default('')->nullable();
            $table->dateTime('last_login_time')->nullable();
            $table->string('token')->default('')->nullable();
            $table->dateTime('token_expire_time')->nullable();
            $table->integer('sex')->nullable()->default('0');
            $table->string('birthday')->nullable()->default('');
            $table->text('description')->nullable();
            $table->string('realname')->nullable();
            $table->integer('is_verifier')->nullable()->default('0');
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('phone');
            $table->string('email')->nullable(false)->change();
            $table->unique('email');
            $table->string('name')->nullable(false)->change();
            $table->string('password')->nullable(false)->change();
            $table->dropColumn('head_id');
            $table->dropColumn('status');
            $table->dropColumn('last_login_ip');
            $table->dropColumn('last_login_time');
            $table->dropColumn('token');
            $table->dropColumn('token_expire_time');
            $table->dropColumn('sex');
            $table->dropColumn('birthday');
            $table->dropColumn('description');
            $table->dropColumn('realname');
            $table->dropSoftDeletes();
        });
    }
};
